import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/home',
    name: 'Home',
    component: Home,
    children: [
      {
        path: '/login',
        name: 'login',
        component: () => import(/* webpackChunkName: "about" */ '../views/login.vue')
      },
      {
        path: '/baberrage',
        name: 'baberrage',
        component: () => import(/* webpackChunkName: "about" */ '../components/baberrage.vue')
      },
      {
        path: '/index',
        name: 'index',
        component: () => import(/* webpackChunkName: "about" */ '../pages/index.vue')
      },
      {
        path: '/qianDao',
        name: 'qianDao',
        component: () => import(/* webpackChunkName: "about" */ '../pages/qianDao.vue')
      },
      {
        path: '/jiang',
        name: 'jiang',
        component: () => import(/* webpackChunkName: "about" */ '../pages/jiang.vue')
      },
      {
        path: '/shake',
        name: 'shake',
        component: () => import(/* webpackChunkName: "about" */ '../pages/Shake.vue')
      },
      {
        path: '/liuYan',
        name: 'liuYan',
        component: () => import(/* webpackChunkName: "about" */ '../pages/liuYan.vue')
      },
      {
        path: '/answer',
        name: 'answer',
        component: () => import(/* webpackChunkName: "about" */ '../pages/answer.vue')
      },
      {
        path: '/vote',
        name: 'vote',
        component: () => import(/* webpackChunkName: "about" */ '../pages/vote.vue')
      },
      {
        path: '/photo',
        name: 'photo',
        component: () => import(/* webpackChunkName: "about" */ '../pages/photo.vue')
      },
      {
        path: '/erWM',
        name: 'erWM',
        component: () => import(/* webpackChunkName: "about" */ '../pages/erWM.vue')
      },
      {
        path: '/setUp',
        name: 'setUp',
        component: () => import(/* webpackChunkName: "about" */ '../pages/setUp.vue')
      },
      {
        path: '/photoWall',
        name: 'photoWall',
        component: () => import(/* webpackChunkName: "about" */ '../pages/photoWall.vue')
      },
      {
        path: '/photoWallSystem',
        name: 'photoWallSystem',
        component: () => import(/* webpackChunkName: "about" */ '../pages/photoWallSystem.vue')
      },
      {
        path: '/packetWall',
        name: 'packetWall',
        component: () => import(/* webpackChunkName: "about" */ '../pages/packetWall.vue')
      },
    ]
  },
  {
    path: '/nine',
    name: 'nine',
    component: () => import(/* webpackChunkName: "about" */ '../pages/nine.vue')
  },
  {
    path: '/nine2',
    name: 'nine2',
    component: () => import(/* webpackChunkName: "about" */ '../pages/nine2.vue')
  },

]

const router = new VueRouter({
  routes
})

router.beforeEach((to, from, next) => {
  if (to.path === '/login') return next()
  const systemId = sessionStorage.systemId
  if (!systemId) return next('/login')
  return next()
})




export default router
